package com.hongdee.crm.tdc.controller;

import com.github.pagehelper.PageInfo;
import com.hongdee.common.util.TokenUtil;
import com.hongdee.crm.tdc.service.ICallRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhangkai
 * @desc 一句话描述
 **/
@RequestMapping("/crm/tdc/call")
@RestController
public class CallRecordController {

    @Autowired
    ICallRecordService callRecordService;

    @RequestMapping("/page")
    @ResponseBody
    public Map page(@RequestParam(name = "uid", defaultValue = "") String uid,
                    @RequestParam(name = "token", defaultValue = "") String token,
                    @RequestParam(name = "vin", defaultValue = "") String vin,
                    @RequestParam(name = "plateNum", defaultValue = "") String plateNum,
                    @RequestParam(name = "orderNum", defaultValue = "") String orderNum,
                    @RequestParam(name = "sa", defaultValue = "") String sa,
                    @RequestParam(name = "page", defaultValue = "0") int page,
                    @RequestParam(name = "limit", defaultValue = "10") int limit
    ) throws Exception {
        String companyId = TokenUtil.getCompanyId(uid);

        PageInfo info = callRecordService.queryPage(page, limit, companyId, vin, plateNum, sa, orderNum);
        Map map = new HashMap(10);
        map.put("total", info.getTotal());
        map.put("dataList", info.getList());
        map.put("success", true);
        map.put("msg", "查询成功");
        return map;
    }


}
